<?php
/**
 * Created by PhpStorm.
 * User: pc
 * Date: 2018/3/31
 * Time: 3:07
 */
namespace app\hook\behaviors;

use app\admin\model\LogsModel;

class logsBehavior
{

    /*
     * 单行为模式
     * */
    public function run(&$params){
        $u_ip = getIP();
        $uid = $_SESSION["user_id"];
        $log = [
            'op_id' => $uid,
            'op_ip' => $u_ip,
            'op_type' => $params[0],
            'op_module' => $params[1],
            'created_at' => time()
        ];
        $op_text = str_replace("op_type",$params[0],$params[2]);
        $op_text = str_replace('#',$params[3],$op_text);
        $log['op_text']=$op_text;
        LogsModel::add($log);
    }

}